package com.zxy.study.ui.activity;

import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.zxy.study.R;
import com.zxy.study.databinding.MvvmBinding;
import com.zxy.study.bean.User;

public class MVVMDemoActivity extends AppCompatActivity {

    private User mUser;
    private MvvmBinding binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = DataBindingUtil.setContentView(this, R.layout.activity_mvvm_demo);
        mUser = new User("zxy", 27);
        binding.setUser(mUser);
        binding.setHandler(new ClickHandler());
    }

    public class ClickHandler  {

        public void changeName() {
            mUser.setName("张小勇");
        }
    }
}
